package org.daochong.fastdev.funcs;

import java.sql.SQLException;

import org.daochong.fastdev.Context;
import org.daochong.fastdev.Function;
import org.daochong.fastdev.util.FastDevUtils;
import org.daochong.lang.BeanUtil;

public class AttrsFunction implements Function {

	public boolean is(String id) {
		return FastDevUtils.operEntity("attrs", id);
	}

	public void exec(String key, String prop, Context context) throws SQLException {
		String act = null;
		if (key.lastIndexOf('.') > 0) {
			act = key.substring(key.lastIndexOf('.') + 1);
		} else {
			return;
		}
		act = BeanUtil.formatString(act, context);
		Object o = context.searchValue(prop);
		context.setAttribute(act, o);
	}

}
